package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SimpleSample {
	public static void main( String args[]) {
		 
		String connectionURL = "jdbc:jtds:sqlserver://172.20.230.27:1433;INSTANCE=YB_DB_SERVER;databaseName=KeywordToolInsertion;user=sa;password=1010Ybpass";
		// Change the connection string according to your db, ip, username and password
		Connection con = null;
		try {
		 
		    // Load the Driver class.
		    Class.forName("net.sourceforge.jtds.jdbc.Driver");
		    // If you are using any other database then load the right driver here.
		 
		    //Create the connection using the static getConnection method
		    con = DriverManager.getConnection (connectionURL);
		 
		    //Create a Statement class to execute the SQL statement
		    Statement stmt = con.createStatement();
		 
		    //Execute the SQL statement and get the results in a Resultset
		    ResultSet rs = stmt.executeQuery("select statecode from state");
		 
		    // Iterate through the ResultSet, displaying two values
		    // for each row using the getString method
		 
//		    while (rs.next())
//		        System.out.println("Name= " + rs.getString("moviename") + " Date= " + rs.getString("releasedate"));
		}
		catch (SQLException e) {
		    e.printStackTrace();
		}
		catch (Exception e) {
		    e.printStackTrace();
		}
		finally {
		    // Close the connection
		    try {
				con.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		}
}
